package com.example.tool.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.tool.R;

import java.util.List;

/**
 * Created Date 2019/9/23
 *
 * @author liangkun
 * description：多个
 */
public class MultiAdapter extends BaseMultiItemQuickAdapter<MultipleItem, BaseViewHolder> {
    public MultiAdapter(@Nullable List<MultipleItem> data) {
        super(data);
        //添加不同的item
        addItemType(MultipleItem.TEXT, R.layout.rv_item_text_view);
        addItemType(MultipleItem.IMG, R.layout.item_pic_text);
        addItemType(MultipleItem.IMG_TEXT, R.layout.item_img_text_view);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MultipleItem item) {
        switch (helper.getItemViewType()) {
            case MultipleItem.TEXT:
                helper.setText(R.id.tv, item.getContent());
                break;
            case MultipleItem.IMG_TEXT:
                switch (helper.getLayoutPosition() % 2) {
                    case 0:
                        helper.setImageResource(R.id.iv, R.mipmap.iv_aion);
                        break;
                    case 1:
                        helper.setImageResource(R.id.iv, R.mipmap.iv_rexue);
                        break;
                    default:
                        break;

                }
                break;
            default:
                break;
        }
    }


}
